
var form,layedit,layer,laydate;

layui.use(['form', 'layedit','layer','laydate'], function(){

    form = layui.form;
    layer = layui.layer
    layedit = layui.layedit
    laydate = layui.laydate;

})
var today;//new 出当前时间
function today(){//构建方法
    today=new Date();
    var h=today.getFullYear();//获取年
    var m=today.getMonth()+1;//获取月
    var d=today.getDate();//获取日
    var H = today.getHours();//获取时
    var M = today.getMinutes();//获取分
    var S = today.getSeconds();//获取秒
    return h+"-"+m+"-"+d+" "+H+":"+M+":"+S; //返回 年-月-日 时:分:秒
}
document.getElementById("start_time").value = today();//将获取到的 年-月-日 时:分:秒 赋给input文本输入框

layui.use(['laydate', 'table'], function() {
    var laydate = layui.laydate;

    var table = layui.table;
    //原有表格日期渲染
    laydate.render({
        elem: '.dateInput',
        min: minDate(),
        type: 'datetime'
    }); // 设置最小可选的日期
    function minDate() {
        var now = new Date();
        var thetime = now.getFullYear() + "-" + (now.getMonth() + 1) + "-" + now.getDate()+" "+(now.getHours()+1)+":"+now.getMinutes()+":"+(now.getSeconds()-1);
        return thetime;
    }
});
//标题验证
layui.use(['form', 'layedit', 'laydate'], function(){
    var form = layui.form;
    //自定义验证规则
    form.verify({
        activityName: function(value){
            if(value ==""|| value==null){
                return '活动名不能为空';
            }
            else if(!new RegExp("[0-9\u4e00-\u9fa5a-zA-Z]+$").test(value)){
                return '活动名不能有特殊字符';
            }
            else if(value.length > 12){
                return '活动名不能超过12个字';
            }else if(value.length < 3){
                return '活动名不能小于3个字';
            }
        },
        activitySite:function (value) {
          if (value==""||value==null){
              return"所在区域不能为空"
          }

        }
    });
});
function  jia() {
    var zhi = document.getElementById("ipt");
    zhi.value = parseInt(zhi.value) + 1;
}
function jian() {
    var zhi = document.getElementById("ipt");
    if (zhi.value > 0) {
        zhi.value = parseInt(zhi.value) - 1;
    }
}
